package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {

    private Logger logger = LoggerFactory.getLogger(PaymentController.class);

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> HashMap = new HashMap<>();
    static{
        HashMap.put(1L,new Payment(1L,"1235566"));
        HashMap.put(2L,new Payment(2L,"12321321fasadsad"));
        HashMap.put(3L,new Payment(3L,"dasdsagsfSFsfsaf"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){
        Payment payment = HashMap.get(id);
        CommonResult<Payment> result = new CommonResult<Payment>(200,"from mysql,serverPort:" + serverPort,payment);
        return result;
    }
}
